using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class StoreMappingMap : EntityTypeConfiguration<StoreMapping>
    {
        public StoreMappingMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.EntityName)
                .IsRequired()
                .HasMaxLength(400);

            // Table & Column Mappings
            this.ToTable("StoreMapping");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.EntityId).HasColumnName("EntityId");
            this.Property(t => t.EntityName).HasColumnName("EntityName");
            this.Property(t => t.StoreId).HasColumnName("StoreId");

            // Relationships
            this.HasRequired(t => t.Store)
                .WithMany(t => t.StoreMappings)
                .HasForeignKey(d => d.StoreId);

        }
    }
}
